#include <iostream>
#include<boost/asio.hpp>

#include "standard.hpp"
#include "rts_client_factory.hpp"
#include "rts_message_receiver.hpp"
#include "rts_server.hpp"

int main(UNUSED(int argc), UNUSED(char **argv))
{
    try
    {
        boost::asio::io_service io_service;
        boost::shared_ptr<logger> l = logger::create("logger.log");
        boost::shared_ptr<rts_client_factory> rcf(new rts_client_factory());
        boost::shared_ptr<rts_message_receiver> rmr(new rts_message_receiver());

        rts_server server(io_service,
                                 8181,
                                 l,
                                 rcf,
                                 "http://www.prism.gatech.edu",
                                 "ws://98.251.48.203:8181/4911-game",
                                 rmr);
        server.start_accept();

        l->log(logger::info, "Server started");
        io_service.run();

        return 0;
    }
    catch(std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        return 1;
    }

    catch(...)
    {
        std::cerr << "Oh dear this is probably bad." << std::endl;
        return 1;
    }
}
